import React, { memo,useEffect } from 'react'
import { connect } from 'react-redux'
import { rootState } from '@/store'
import { Dispatch,AnyAction } from 'redux'
import { getPartitions } from '@/store/actions/patitions'
import { PartitionType } from '@/models/PartitionTypes'

interface HomeProps {
  loading:boolean;
  partitions:PartitionType;
  getPartitionsDispatch: () => void;
}

const Home:React.FC<HomeProps> = (props) => {
  const { loading,partitions } = props;
  const { getPartitionsDispatch } = props;
  useEffect(() => {
    getPartitionsDispatch();
  },[])
  console.log(partitions)

  return (
    <div>
      {loading && <div>加载中...</div>}
    </div>
  )
}

const mapStateToProps = (state:rootState) => ({
  hotword: state.search.hotword,
  loading: state.loading,
  partitions: state.home.partitions
})

const mapDiapatchToProps = (dispatch:Dispatch) => ({
  getPartitionsDispatch(){
    dispatch(getPartitions())
  }
})
export default connect(mapStateToProps,mapDiapatchToProps)(memo(Home))